package Game.AiStates 
{
	import flash.geom.Point;
	import Game.AiShip;
	import Game.MainGame;
	/**
	 * ...
	 * @author Vijay
	 */
	public class StateFeed implements AiState 
	{
		/*
			
			
			if another ship in firing range switch state to StateAttack
			
		*/
		
		private var aiShip:AiShip = null;
		
		public function StateFeed()
		{
		}
		
		/* INTERFACE Game.AiStates.AiState */
		
		public function PreUpdate(_ship:AiShip):void 
		{
			aiShip = _ship;
		}
		
		public function Update():void 
		{
			var _targ:Point = aiShip.DirClosestEnergy;
			var _ang:Number = _targ.x * aiShip.Direction.x + _targ.y * aiShip.Direction.y;
			
			if (_ang < Math.cos(3 * Math.PI / 180))
			{
				var _turnDir:Number = aiShip.Direction.y * _targ.x - aiShip.Direction.x * _targ.y;
				if (_turnDir > 0) aiShip.TurnLeft();
				else aiShip.TurnRight();
			}
		}
		
		public function PostUpdate():void 
		{
			
		}
		
	}

}